package net.openl10n.packaging;


public final class IdPartPair {

	private final String relationshipId;
	private final OpenLocPart part;
	
	public IdPartPair(String relationshipId, OpenLocPart part){
		if(relationshipId == null || "".equals(relationshipId))
			throw new IllegalArgumentException("relationshipId");
		if(part == null)
			throw new IllegalArgumentException("part");
			
		this.relationshipId = relationshipId;
		this.part = part;
	}
	
	public String getRelationshipId() {
		return relationshipId;
	}
	
	public OpenLocPart getPart() {
		return part;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;
		if( !(obj instanceof IdPartPair) ) return false;
		IdPartPair other = (IdPartPair) obj;
		return ( super.equals(other) 
				&& other.relationshipId.equals(relationshipId) && other.part.equals(part));
	}
	
	@Override
	public int hashCode() {
	    int hash = 1;
	    hash = hash * 31 + relationshipId.hashCode();
	    hash = hash * 31 + part.hashCode();
	    return hash;
	}
	
}
